package com.lpl.service.impl;

import com.lpl.polo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Issues implements com.lpl.service.Issues {
    @Autowired
    private com.lpl.mapper.getIssues getIssues;

    @Override
    public List<Question> serIssues(String  name) {
System.out.println(name);

        List<Question> u= getIssues.seckemi(name);

        return u;
    }

    @Override
    public List<Question>  getdetails(int id) {
        System.out.println(id+"sdsd");

        Question u=  getIssues.seckemiId(id);
        List<Question> us=  getIssues.shitiiId(id);

        System.out.println(u);
        if(us!=null){
            for (Question question : us) {
                System.out.println("Question id: " + question.getId());
                List<Option> s=getIssues.getQuestion(question.getId());

                question.setOptions(s);

            }

        }

        return us;
    }

    @Override
    public result insertimu(kemu question) {
        getIssues.insetimu(question);
        return null;
    }

    @Override
    public void shanchu(String id) {
        getIssues.shanchu(id);
    }

    @Override
    public void baijji(kemu data) {
        getIssues.bianji(data);
    }

    @Override
    public List<Question>  gettimu(tishai data) {
        List<Question> u= getIssues.getTimu(data);
System.out.println(data);
        return u;
    }

    @Override
    public newq isetimu(newq data) {
        getIssues.IseTimu(data);
        return null;
    }

    @Override
    public void isexuan(Option data) {
        getIssues.Isexuan(data);
    }

    @Override
    public List<Option>  getxuan(Integer id) {
        List<Option> u= getIssues.getQuestion(id);
        return u;
    }

    @Override
    public void shangetxuan(Integer id) {
        getIssues.shanget(id);
    }

    @Override
    public int shangetxuanx(Integer id) {
       int num  = getIssues.shangets(id);
       return num;
    }

    @Override
    public int xiutimu(newq data) {

        System.out.println(data);
        int num  = getIssues.xiuti(data);

        return 1;
    }

    @Override
    public void xiuxuan(Option item) {

        System.out.println(item);
      getIssues.xiutixuan(item);
    }

    @Override
    public void tianjiatu(img data) {
        getIssues.tianjiatu(data);
    }

    @Override
    public List<img> getjiatu() {
        List<img> u=  getIssues.getjiatu();
        return u;
    }

    @Override
    public List<img> shanjiatu(int id) {
        getIssues.shanjiatu(id);
        return null;
    }
}
